package com.atde._05_behavioral_design_patterns.state.app;


/**
 * @BelongsProject: hsp_java_design_mode
 * @BelongsPackage: com.atde._05_behavioral_design_patterns.state.app
 * @Author: Del
 * @CreateTime: 2025-06-30  11:28
 * @Description: 状态模式 --- 具体的状态类 --- 表示当前为发放奖品状态
 * @Version: 1.0
 */
public class DispenseState extends State{

    // 初始化时传入活动引用，发放奖品后改变其状态
    RaffleActivity activity;

    public DispenseState(RaffleActivity activity) {
        this.activity = activity;
    }

    @Override
    void deductMoney() {
        System.out.println("不能扣除积分");
    }

    @Override
    boolean raffle() {
        System.out.println("不能抽奖");
        return false;
    }

    @Override
    void dispensePrize() {
        if (activity.getCount() > 0) {
            System.out.println("恭喜中奖了！");
            // 改变状态为不能抽奖
            activity.setState(activity.getNoRaffleState());
        } else {
            // 改变状态为奖品发送完毕
            activity.setState(activity.getDispenseOutState());
        }
    }
}
